package com.example.enterprise

import android.os.Bundle
import androidx.activity.viewModels
import androidx.appcompat.app.AppCompatActivity
import androidx.core.view.ViewCompat
import androidx.core.view.WindowInsetsCompat
import com.alibaba.android.arouter.facade.annotation.Autowired
import com.alibaba.android.arouter.facade.annotation.Route
import com.alibaba.android.arouter.launcher.ARouter
import com.blankj.utilcode.util.ToastUtils
import com.bumptech.glide.Glide
import com.example.common.view.view.BaseMvvmActivity
import com.example.enterprise.databinding.ActivityEnterpriseXiangBinding
import com.example.enterprise.vm.EnterpriseViewModel
import com.example.image.glide.GlideImgLoader
import dagger.hilt.android.AndroidEntryPoint

@AndroidEntryPoint
@Route(path = "/enterprise/EnterpriseXiangActivity")
class EnterpriseXiangActivity : BaseMvvmActivity<ActivityEnterpriseXiangBinding>() {
    override fun getLayoutId(): Int =R.layout.activity_enterprise_xiang
    @Autowired
    @JvmField
    var enterpriseId:Int=0

    val enterpriseViewModel:EnterpriseViewModel by viewModels()
    override fun initView() {
        super.initView()
        ARouter.getInstance().inject(this)
        enterpriseViewModel.getEnterpriseById(enterpriseId)
        enterpriseViewModel.mSuccessLiveData.observe(this){
            it.data.forEach {
                mDataBinding.eName.text=it.name
                mDataBinding.eIndustryType.text=it.industryType
                mDataBinding.eAddress.text=it.address
                mDataBinding.eLegalRepresentative.text=it.legalRepresentative
                mDataBinding.eContactInfo.text=it.contactInfo
                mDataBinding.eStatus.text=it.status
                mDataBinding.eStockName.text=it.stockName
                mDataBinding.eStockCode.text=it.stockCode
                if (it.listed){
                    mDataBinding.eListed.text="是"
                }else{
                    mDataBinding.eListed.text="否"
                }
               Glide.with(this).load(R.drawable.ic_icon_photo).into(mDataBinding.ePhotos)
            }
        }
        enterpriseViewModel.mErrorLiveData.observe(this){
            ToastUtils.showLong(it)
        }
    }

}